package com.shenyi.mould.rest.controller.wx;

import com.shenyi.core.utils.R;
import com.shenyi.core.utils.validator.Assert;
import com.shenyi.wx.annotation.IgnoreAuth;
import com.shenyi.wx.api.IApiUserService;
import com.shenyi.wx.util.ApiBaseAction;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author richard.fan
 * @version 1.0
 * @date 2018/11/07
 * @desc 注册
 * @see
 * @since 1.0
 */
@Api(tags = "注册")
@RestController
@RequestMapping("/api/register")
public class ApiRegisterController extends ApiBaseAction {

    @Autowired
    private IApiUserService userService;

    /**
     * 注册
     */
    @ApiOperation(value = "注册")
    @IgnoreAuth
    @PostMapping("register")
    public R register(String mobile, String password) {
        Assert.isBlank(mobile, "手机号不能为空");
        Assert.isBlank(password, "密码不能为空");

        userService.save(mobile, password);

        return R.ok();
    }
}
